package com.company;

import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void testSet(){
        Vector vo = new Vector();
        for (int i = 0;i<10;i++){
            vo.add(i);
        }
        System.out.println(vo);

        ArrayList ao = new ArrayList();
        ao.addAll(vo);
        System.out.println(ao);


        LinkedList<Integer> lo = new LinkedList<Integer>();
        lo.addAll(ao);
        lo.removeIf(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) {
                return  integer%2 == 0;
            }
        });
        System.out.println(lo);

        HashSet ho = new HashSet();
        //ho.addAll(lo);
        ho.add(101);
        ho.add(11);
        // ho.addAll(vo);
        System.out.println(ho);

        TreeSet to = new TreeSet();
        to.addAll(ho);
        System.out.println(to);

        HashMap hmo = new HashMap();
        hmo.put("k12","v2");
        hmo.put("k2","v2");
        hmo.put("k1","v2");
        System.out.println(hmo);

        LinkedHashMap lhmo = new LinkedHashMap();
        lhmo.put("k12","v2");
        lhmo.put("k2","v2");
        lhmo.put("k1","v2");
        System.out.println(lhmo);

        TreeMap tmo = new TreeMap();
        tmo.putAll(hmo);
        System.out.println(tmo);

        //Hashtable hto = new Hashtable();
        // Dictionary;Hashtable;
        // Properties;BitSet;
    }

    public static void testMutiBuffer(){
        MutiBufferQueue<Object> mutiQueue = new MutiBufferQueue<Object>(0);
        Producer producer = new Producer("producer",mutiQueue);
        Consumer consumer = new Consumer("consumer",mutiQueue);
        Monitor monitor = new Monitor("monitor",mutiQueue);
        for (int i = 0;i < 10;i++){
            Thread pt = new Thread(producer);
            pt.start();
        }
        for (int i = 0;i < 10;i++){
            Thread ct = new Thread(consumer);
            ct.start();
        }

        Thread mt = new Thread(monitor);
        mt.start();
    }

    public static void main(String[] args) throws InterruptedException {
        TestThread.testBadCounter();
        TestThread.testAppleCounter();
        TestThread.testMongoCounter();
        TestThread.testBananaCounter();
        //TestThreadPool.testThreadPool();
        //TestFutureThread.test();
        TestFutureThread.testCompletable2();
    }
}
